package com.hmall.common.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;

import java.util.Date;

//公共字段填充
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
        this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
        //this.strictInsertFill(metaObject, "createBy", Long.class, 1L); // 假设创建人ID为1
        //this.strictInsertFill(metaObject, "updateBy", Long.class, 1L); // 假设更新人ID为1
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
      //  this.strictUpdateFill(metaObject, "updateBy", Long.class, 1L); // 假设更新人ID为1
    }
}